<?php
/**
 * WarehousesController.php
 *
 * @copyright   2023 thingsworld.com.cn - All Rights Reserved
 * @link        http://thingsworld.com.cn/
 * @author      stiffer.chen <chenl@thingsworld.com.cn>
 * @created     2023-05-11 15:24:56
 * @modified    2023-05-11 15:24:56
 *
 */

namespace App\Http\Controllers;

use App\Repositories\WarehouseRepo;
use Illuminate\Http\Request;

class WarehousesController extends BaseModuleController
{
    public function index(Request $request)
    {
        try {
            $warehouses = WarehouseRepo::getList();
            return list_message('获取成功', true, $warehouses);
        } catch (\Exception $e) {
            return message($e->getMessage(), false);
        }
    }

    public function store(Request $request)
    {
        try {
            $warehouse = WarehouseRepo::store();
            return message('保存成功', true, $warehouse);
        } catch (\Exception $e) {
            return message($e->getMessage(), false);
        }
    }

    public function update(Request $request, $id)
    {
        try {
            $warehouse = WarehouseRepo::store($id);
            return message('保存成功', true, $warehouse);
        } catch (\Exception $e) {
            return message($e->getMessage(), false);
        }
    }

    public function show(Request $request, $id)
    {
        try {
            $warehouse = WarehouseRepo::fetch($id);
            return message('获取成功', true, $warehouse);
        } catch (\Exception $e) {
            return message($e->getMessage(), false);
        }
    }
}